#include "peh.h"

void ErrorExit(const char* lpszFunction)
{
	LPVOID lpMsgBuf;
	char Mes[1024] = { 0, };
	LPVOID lpDisplayBuf;
	DWORD dw = GetLastError();

	FormatMessageA(
		FORMAT_MESSAGE_ALLOCATE_BUFFER |
		FORMAT_MESSAGE_FROM_SYSTEM |
		FORMAT_MESSAGE_IGNORE_INSERTS,
		NULL,
		dw,
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
		(LPSTR)& lpMsgBuf,
		0, NULL);

	sprintf_s(Mes, "[!]%s failed with error 0x%x: %s\n", lpszFunction, dw, lpMsgBuf);
	printf(Mes);
	//MessageBoxA(NULL, Mes, "failed!", MB_OK);
	//ExitProcess(dw);
}

//void Check()
//{
//	if (!GetProcessId(NULL))
//		ErrorExit("GetProcessId");
//}
